package br.com.busgps.crawler;

import java.io.IOException;
import java.util.List;

import br.com.busgps.bean.Bus;
import br.com.busgps.mapper.json.Result;
import br.com.busgps.util.Constants;
import br.com.busgps.util.ResultConnection;

public class Teste
{
    public static void percurso() throws IOException
    {
        StringBuilder sb = new StringBuilder(Constants.REQUEST_LOCATION_URL);

        /** Obtem os dados do servidor */
        Result result = ResultConnection.getData(sb.toString());

        if (result != null)
        {
            for (List<String> data : result.getDATA())
            {
                String order = data.get(1);
                String number = data.get(2);

                if (data.get(2).length() > 2)
                {
                    if (data.get(2).endsWith(".0"))
                    {
                        number = data.get(2).replace(".0", "");
                    }
                    Bus b = new Bus(order, number);
                    System.out.println(b);
                }
            }
        }
    }

    public static void main(String[] args)
    {

    }

}